package day06;

import java.util.Arrays;

public class ArrayDemo {
    public static void main(String[] args) {
        //6)数组的复制:
        int[] arr = new int[10];
        for (int i=0;i<arr.length;i++){
            arr[i] = (int) (Math.random()*100);
            System.out.println(arr[i]);
        }

        int max = arr[0];
        for (int i=1;i<arr.length;i++){
            if (arr[i]>max){
                max = arr[i];
            }
        }
        System.out.println("最大值为:"+max);

        arr = Arrays.copyOf(arr,arr.length+1); //扩容
        arr[arr.length-1] = max; //将max赋值给arr的最后一个元素
        for (int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }







        /*
        int[] b = new int[6];
        //a:源数组
        //1:源数组的起始下标
        //b:目标数组
        //0:目标数组的起始下标
        //4:要复制的元素下标
        System.arraycopy(a,1,b,0,4);
        for (int i=0;i<b.length;i++){
            System.out.println(b[i]);
        }
         */
    }
}
